package com.bit.deom;


import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component
@Slf4j
public class AspectDemo {

    @Pointcut("execution(* com.bit.deom.controller.*.*(..))")
    public void pt(){}
    @Before("pt()")
    public void before(){
        log.info("before");
    }

    @After("pt()")
    public void after(){
        log.info("after");
    }

    @AfterReturning("pt()")
    public void afterReturning(){
        log.info("afterReturning");
    }

    @AfterThrowing("pt()")
    public void afterThrowing(){
        log.info("afterThrowing");
    }

    @Around("pt()")
    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
        log.info("Around 开始执行......");
        Object result = joinPoint.proceed();
        log.info("Around 结束执行......");
        return result;
    }
}
